/**
 * Created by yuming619 on 2016/11/25.
 */
//服务
angular.module('mealplan.service.user', ['ngResource'])

//用户服务
    .service('UserService',  ['$resource', function ($resource) {
        var resource = $resource(authurl + "user/:id");
        //通过name,获取good
        this.getuserbyid = function (id) {
            return resource.get({id: id});
        }
        this.getuserbyname = function (name, success, error) {
            var resource = $resource(authurl + "user/byname/:name");
            return resource.get({name: name}, success, error);
        }
        this.add = function (user, success, error) {
            var resource = $resource(authurl + "user/add/:id");
            return resource.save({}, user, success, error);
        }
        this.update = function (id, user, success, error) {
            return resource.save({id: id}, user, success, error);
        }
        this.remove = function (id) {
            return resource.remove({id: id});
        }
        this.getlist = function () {
            return resource.query();
        }
    }])